﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Mojito.Migrations
{
    public partial class _01 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Request",
                columns: table => new
                {
                    Id = table.Column<string>(maxLength: 50, nullable: false),
                    Title = table.Column<string>(nullable: true),
                    Status = table.Column<short>(nullable: false),
                    Description = table.Column<string>(nullable: true),
                    RequestUrl = table.Column<string>(nullable: true),
                    Method = table.Column<int>(nullable: false),
                    Header = table.Column<string>(nullable: true),
                    Body = table.Column<string>(nullable: true),
                    FolderId = table.Column<string>(nullable: true),
                    TimeStamp = table.Column<long>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Request", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "RequestDirectory",
                columns: table => new
                {
                    Id = table.Column<string>(maxLength: 50, nullable: false),
                    Name = table.Column<string>(nullable: true),
                    ParentId = table.Column<string>(nullable: true),
                    CreateUserId = table.Column<string>(nullable: true),
                    CreateUserDate = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RequestDirectory", x => x.Id);
                    table.ForeignKey(
                        name: "FK_RequestDirectory_RequestDirectory_ParentId",
                        column: x => x.ParentId,
                        principalTable: "RequestDirectory",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "RequestEnviroment",
                columns: table => new
                {
                    Id = table.Column<string>(maxLength: 50, nullable: false),
                    Name = table.Column<string>(nullable: true),
                    Kv = table.Column<string>(nullable: true),
                    WorkspaceId = table.Column<string>(nullable: true),
                    CreateDate = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RequestEnviroment", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "RequestExample",
                columns: table => new
                {
                    Id = table.Column<string>(maxLength: 50, nullable: false),
                    RequestId = table.Column<string>(nullable: true),
                    Reqeust = table.Column<string>(nullable: true),
                    RequestText = table.Column<string>(nullable: true),
                    Response = table.Column<string>(nullable: true),
                    ResponseText = table.Column<string>(nullable: true),
                    Version = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RequestExample", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "RequestShare",
                columns: table => new
                {
                    Id = table.Column<string>(maxLength: 50, nullable: false),
                    AccountId = table.Column<string>(nullable: true),
                    DirectoryId = table.Column<string>(nullable: true),
                    Date = table.Column<DateTime>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RequestShare", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Sys_Account",
                columns: table => new
                {
                    Id = table.Column<string>(maxLength: 50, nullable: false),
                    Username = table.Column<string>(nullable: false),
                    Password = table.Column<string>(nullable: false),
                    TryCount = table.Column<int>(nullable: false),
                    IsActive = table.Column<bool>(nullable: false),
                    Photo = table.Column<string>(nullable: true),
                    Name = table.Column<string>(nullable: true),
                    TelPhone = table.Column<string>(nullable: true),
                    Email = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sys_Account", x => x.Id);
                });

            migrationBuilder.CreateIndex(
                name: "IX_RequestDirectory_ParentId",
                table: "RequestDirectory",
                column: "ParentId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Request");

            migrationBuilder.DropTable(
                name: "RequestDirectory");

            migrationBuilder.DropTable(
                name: "RequestEnviroment");

            migrationBuilder.DropTable(
                name: "RequestExample");

            migrationBuilder.DropTable(
                name: "RequestShare");

            migrationBuilder.DropTable(
                name: "Sys_Account");
        }
    }
}
